import json

from Page import Page
from Page1 import Page1
from Page2 import Page2
from selenium import webdriver
import pytest
import time

#读取json数据
def du(path):
    with open(path,'r',encoding='utf-8')as f:
        data = json.load(f)
        return data

@pytest.fixture(scope='function',autouse=True)
def driver():
    driver = webdriver.Edge()
    driver.maximize_window()
    yield driver
    driver.quit()

#调用登录 方法
def test_01_login(driver):
    po = Page(driver)
    po.luoji_jiuxian()


#json数据驱动：
@pytest.mark.parametrize('data',du(r'E:\gaoer\rk\pythonProject\Day_2304_Test\Unit_ykmn3\jiuxian.json'))
#调用结算商品的方法
def test_02_jiesuan(driver,data):
    #先把登录调用过来
    po = Page(driver)
    po.luoji_jiuxian()
    #开始调用page1结算
    po = Page1(driver)
    time.sleep(2)
    po.shuruk(data['shuruk'])
    time.sleep(2)
    po.enter()
    time.sleep(2)
    po.sp()
    time.sleep(2)
    po.qiehuan()
    time.sleep(2)
    po.gouwuche()
    driver.implicitly_wait(10)
    po.look()
    time.sleep(4)
    po.jiesuan()
    time.sleep(8)

#调用提交修改地址的方法
def test_03_adress(driver):
    #把登录调用过来
    po = Page(driver)
    po.luoji_jiuxian()
    #开始调用Page2的修改地址
    po = Page2(driver)
    #业务流程
    time.sleep(2)
    po.myjx()
    time.sleep(2)
    po.qiehuan2()
    time.sleep(2)
    po.gundong()
    time.sleep(2)
    po.address()
    time.sleep(2)
    po.shouhuoren()
    time.sleep(2)
    po.diqu1()
    time.sleep(2)
    po.diqu2()
    time.sleep(2)
    po.diqu3()
    time.sleep(2)
    po.tijiao()
    time.sleep(6)
